package sync.hw.teacher.demo01;

/**
 * @author lwj
 * @date 2025-03-13
 * @vesion 1.0.0
 */
public class Account {
    /**
     * 余额
     */
    private double money;

    // 构造方法
    public Account() {}
    public Account(double money) {
        this.money = money;
    }

    /**
     * 取钱
     *
     * @param user 取钱用户
     * @param money 取钱的金额
     * @return 钱
     */
    public void getMoney(String user,double money) {
        System.out.printf("%s取了%.1f元,",user,money);

        // 余额充足
        if(this.money > money){

            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            this.money -= money;
            System.out.printf("还剩余额为：%.1f!%n",this.money);
            return;
        }
        // 余额不充足
        System.out.println("取款失败，余额不足！");
    }

    /**
     * 存钱 此练习不管存钱
      */

    public void setMoney(String user,double money) {
        this.money = money;
    }
}
